<?php

/**
 * MailingList form base class.
 *
 * @package    form
 * @subpackage mailing_list
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 8508 2008-04-17 17:39:15Z fabien $
 */
class BaseMailingListForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_mailing_list'  => new sfWidgetFormInputHidden(),
      'id_mailing_group' => new sfWidgetFormDoctrineChoice(array('model' => 'MailingGroup', 'add_empty' => true)),
      'ds_nome_list'     => new sfWidgetFormInput(),
      'ds_email_list'    => new sfWidgetFormInput(),
      'st_mailing_list'  => new sfWidgetFormInput(),
      'st_envio_list'    => new sfWidgetFormInput(),
      'dt_envio_list'    => new sfWidgetFormDateTime(),
      'created_at'       => new sfWidgetFormDateTime(),
      'updated_at'       => new sfWidgetFormDateTime(),
      'deleted'          => new sfWidgetFormInputCheckbox(),
    ));

    $this->setValidators(array(
      'id_mailing_list'  => new sfValidatorDoctrineChoice(array('model' => 'MailingList', 'column' => 'id_mailing_list', 'required' => false)),
      'id_mailing_group' => new sfValidatorDoctrineChoice(array('model' => 'MailingGroup', 'required' => false)),
      'ds_nome_list'     => new sfValidatorString(array('max_length' => 80)),
      'ds_email_list'    => new sfValidatorString(array('max_length' => 100)),
      'st_mailing_list'  => new sfValidatorInteger(array('required' => false)),
      'st_envio_list'    => new sfValidatorInteger(array('required' => false)),
      'dt_envio_list'    => new sfValidatorDateTime(array('required' => false)),
      'created_at'       => new sfValidatorDateTime(array('required' => false)),
      'updated_at'       => new sfValidatorDateTime(array('required' => false)),
      'deleted'          => new sfValidatorBoolean(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'MailingList', 'column' => array('ds_email_list')))
    );

    $this->widgetSchema->setNameFormat('mailing_list[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'MailingList';
  }

}
